The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
Changes 06
META.yml 12
Makefile.PL 01
lib/App/perlbrew.pm 1862
t/installation.t 10
5 files changed (This is a version diff) 2071
@@ -1,3 +1,9 @@
+0.23:
+- dependency fixes
+- Fix auto-detection of curl
+- Support OpenBSD pdksh. The provided bashrc should be compatible with pdksh.
+- Small improvement of 'exec' command. `perlbrew exec perl -v` now works.
+
 0.22:
 - Fix ccache support on Linux with bash.. GH #87.
 - `install` command no longer clobbers existing installations.
@@ -4,6 +4,7 @@ author:
   - 'Kang-min Liu  C<< <gugod@gugod.org> >>'
 build_requires:
   ExtUtils::MakeMaker: 6.42
+  IO::All: 0
   Path::Class: 0
   Test::Exception: 0
   Test::More: 0
@@ -30,4 +31,4 @@ requires:
 resources:
   license: http://opensource.org/licenses/mit-license.php
   repository: git://github.com/gugod/App-perlbrew.git
-version: 0.22
+version: 0.23
@@ -56,6 +56,7 @@ test_requires 'Test::More';
 test_requires 'Test::Output';
 test_requires 'Test::Exception';
 test_requires 'Path::Class';
+test_requires 'IO::All';
 
 install_script 'bin/perlbrew';
 
@@ -5,10 +5,11 @@ use 5.008;
 use Getopt::Long ();
 use File::Spec::Functions qw( catfile );
 
-our $VERSION = "0.22";
+our $VERSION = "0.23";
 our $CONF;
 
 my $ROOT         = $ENV{PERLBREW_ROOT} || "$ENV{HOME}/perl5/perlbrew";
+my $PB_HOME      = $ENV{PERLBREW_HOME} || "$ENV{HOME}/.perlbrew";
 my $CONF_FILE    = catfile( $ROOT, 'Conf.pm' );
 my $CURRENT_PERL = $ENV{PERLBREW_PERL};
 
@@ -16,24 +17,28 @@ sub current_perl { $CURRENT_PERL || '' }
 
 sub BASHRC_CONTENT() {
     return <<'RC';
-if [[ -f $HOME/.perlbrew/init ]]; then
-    source $HOME/.perlbrew/init
+if [[ -z "$PERLBREW_HOME" ]]; then
+    export PERLBREW_HOME=$HOME/.perlbrew
+fi
+
+if [[ -f $PERLBREW_HOME/init ]]; then
+    . $PERLBREW_HOME/init
 fi
 
 __perlbrew_reinit () {
-    if [[ ! -d $HOME/.perlbrew ]]; then
-        mkdir -p $HOME/.perlbrew
+    if [[ ! -d $PERLBREW_HOME ]]; then
+        mkdir -p $PERLBREW_HOME
     fi
 
-    echo '# DO NOT EDIT THIS FILE' >| $HOME/.perlbrew/init
-    command perlbrew env $1 >> $HOME/.perlbrew/init
-    source $HOME/.perlbrew/init
+    echo '# DO NOT EDIT THIS FILE' >| $PERLBREW_HOME/init
+    command perlbrew env $1 >> $PERLBREW_HOME/init
+    . $PERLBREW_HOME/init
     __perlbrew_set_path
 }
 
 __perlbrew_set_path () {
     [[ -z "$PERLBREW_ROOT" ]] && return 1
-    hash -d perl 2>/dev/null
+    unalias perl 2>/dev/null
     export PATH_WITHOUT_PERLBREW=$(perl -e 'print join ":", grep { index($_, $ENV{PERLBREW_ROOT}) } split/:/,$ENV{PATH};')
     export PATH=$PERLBREW_PATH:$PATH_WITHOUT_PERLBREW
 }
@@ -195,7 +200,8 @@ sub uniq(@) {
             );
             for my $command (@commands) {
                 my $program = $command->[0];
-                if (! system("$program --version >/dev/null 2>&1")) {
+                my $code = system("$program --version >/dev/null 2>&1") >> 8;
+                if ($code != 127) {
                     @command = @$command;
                     last;
                 }
@@ -225,6 +231,7 @@ sub new {
     my($class, @argv) = @_;
 
     my %opt = (
+        original_argv  => \@argv,
         force => 0,
         quiet => 1,
         D => [],
@@ -261,6 +268,8 @@ sub new {
     )
       or run_command_help(1);
 
+    $opt{args} = \@ARGV;
+
     # fix up the effect of 'bundling'
     foreach my $flags (@opt{qw(D U A)}) {
         foreach my $value(@{$flags}) {
@@ -268,8 +277,6 @@ sub new {
         }
     }
 
-    $opt{args} = \@ARGV;
-
     return bless \%opt, $class;
 }
 
@@ -395,7 +402,7 @@ sub run_command_init {
     my $HOME = $self->env('HOME');
 
     mkpath($_) for (
-        "$HOME/.perlbrew",
+        "$PB_HOME",
         "$ROOT/perls", "$ROOT/dists", "$ROOT/build", "$ROOT/etc",
         "$ROOT/bin"
     );
@@ -418,20 +425,28 @@ sub run_command_init {
         $shrc = $yourshrc = 'bashrc';
     }
 
-    system("$0 env @{[ $self->current_perl ]}> ${HOME}/.perlbrew/init");
+    system("$0 env @{[ $self->current_perl ]}> ${PB_HOME}/init");
 
     $self->run_command_symlink_executables;
 
     my $root_dir = $self->path_with_tilde($ROOT);
+    my $pb_home_dir = $self->path_with_tilde($PB_HOME);
 
     print <<INSTRUCTION;
 Perlbrew environment initiated, required directories are created under
 
     $root_dir
 
-Paste the following line to the end of your ~/.${yourshrc} and start a
+Paste the following line(s) to the end of your ~/.${yourshrc} and start a
 new shell, perlbrew should be up and fully functional from there:
 
+INSTRUCTION
+
+    if ($PB_HOME ne "$ENV{HOME}/.perlbrew") {
+        print "export PERLBREW_HOME=$pb_home_dir\n";
+    }
+
+    print <<INSTRUCTION;
     source $root_dir/etc/${shrc}
 
 For further instructions, simply run `perlbrew` to see the help message.
@@ -993,7 +1008,7 @@ sub run_command_env {
 
     my %env = $self->perlbrew_env($perl);
 
-    if ($self->env('SHELL') =~ /(ba|z|\/)sh$/) {
+    if ($self->env('SHELL') =~ /(ba|k|z|\/)sh$/) {
         while (my ($k, $v) = each(%env)) {
             print "export $k=$v\n";
         }
@@ -1067,7 +1082,9 @@ USAGE
 }
 
 sub run_command_exec {
-    my ($self, @args) = @_;
+    my $self = shift;
+    my @args = @{$self->{original_argv}};
+    shift @args;
 
     for my $i ( $self->installed_perls ) {
         my %env = $self->perlbrew_env($i->{name});
@@ -1262,7 +1279,7 @@ To use C<perlbrew>, it is required to install C<curl> or C<wget>
 first. C<perlbrew> depends on one of this two external commmands to be
 there in order to fetch files from the internet.
 
-The recommended way to install perlbrew is to run these statements in
+The recommended way to install perlbrew is to run this statement in
 your shell:
 
     curl -L http://xrl.us/perlbrewinstall | bash
@@ -1287,6 +1304,33 @@ a C<PERLBREW_ROOT> environment variable before running the installer:
     export PERLBREW_ROOT=/opt/perlbrew
     curl -L http://xrl.us/perlbrewinstall | bash
 
+By default, C<perlbrew> looks for the intialization file that exports
+C<PERLBREW_ROOT> in C<~/.perlbrew/init>.  In some cases (for instance,
+if your home directory is shared across multiple machines), you may
+wish to have several different perlbrew setting per-machine. If so,
+you can use the C<PERLBREW_HOME> environment variable to tell perlbrew
+where to look for the initialization file.
+
+ # on machine a
+ $ PERLBREW_HOME=~/.perlbrew-a PERLBREW_ROOT=~/perl5/perlbrew-a ./perlbrew install
+
+ # on machine b
+ $ PERLBREW_HOME=~/.perlbrew-b PERLBREW_ROOT=~/perl5/perlbrew-b ./perlbrew install
+
+If you specify C<PERLBREW_HOME>, you will also need to specify both
+C<PERLBREW_HOME> and C<PERLBREW_ROOT> when you first install perlbrew.
+After that, you'll need to make sure C<PERLBREW_HOME> is exported when
+you log in, before you source C<$PERLBREW_ROOT/etc/bashrc> (or
+C<cshrc>). Example C<.bashrc>:
+
+    if [ "$(hostname)" == "machine-a" ]; then
+        export PERLBREW_HOME=~/.perlbrew-a
+        source ~/perl5/perlbrew-a/etc/bashrc
+    elif [ "$(hostname)" == "machine-b" ]; then
+        export PERLBREW_HOME=~/.perlbrew-b
+        source ~/perl5/perlbrew-b/etc/bashrc
+    fi
+
 You may also install perlbrew from CPAN:
 
     cpan App::perlbrew
@@ -10,7 +10,6 @@ BEGIN {
 use Test::More;
 use Test::Exception;
 use App::perlbrew;
-use Try::Tiny;
 
 ## setup